<?
include_once "accesscontrol.php";
require_once("../conn.php");
?>
<style type="text/css" >
table.data {
  background-color:#fff;
   color:#213243;
}
.data th {background-color:gray; color:#ffffff}
.pagingDiv {width:800px; height:20px}
.pNo {float:left; width:10px; margin-left:3px; margin-right:3px; border:0px solid gray;}
.pNo a {text-decoration:none;}
</style>

<?
//-------------------------------PAGING--------------------------------------------

// Number of records to show per page
$recordsPerPage = 2;  # 0

// default startup page
$pageNum = 1;

if(isset($_GET['p'])) {
  $pageNum = $_GET['p'];
  settype($pageNum, 'integer');
}

$offset = ($pageNum - 1) * $recordsPerPage;
//-------------------------------PAGING--------------------------------------------------

$cat_job = $_GET['cat'];

$q1 = "SELECT * FROM job_post WHERE JobCategory = '$cat_job' ORDER BY createdTime DESC LIMIT $offset, $recordsPerPage";
$r1 = mysql_query($q1) or die(mysql_error());
?>

<br>
<br>	

<table align=center border=1 bordercolor=993300 cellspacing=0 width=460>
	<tr>
		<td>
			<table border=0 width=500 cellspacing=0 cellpadding=4>	
							
<?
while($as = mysql_fetch_array($r1))
{
$time = strtotime($as['createdTime']);
$dateAdd = date("d M Y" ,$time);
?>
<table border=0 width=500 cellspacing=0 cellpadding=4>	
<?
if($col == "cococo")
	    { 
	     $col = "dddddd"; 
	    }
	         	 else
		{ 
		$col = "cococo"; 
		} 
?>
<tr bgcolor=<?=$col?>>
		<td width=90>
			<?=$dateAdd?><br><br><br>
		</td>
		<td width=400>
			<a class=BlackLink href="JobInfo.php?job_id=<?=$as[job_id]?>"><font size=3 color=blue><?=$as[position]?></font></a>  ~  <font size=3> <?=$as[Company]?> </font><br>
			<?=$as[CompanyState]?><br>
			<?=$as[short_desc]?>
		</td>
	</tr>
</table>
<?
}
	

//-----------------------------------------PAGING-------------------------------------------
		
	# Update this query with same where clause you are using above.
  $query   = "SELECT COUNT(job_id) AS dt FROM job_post WHERE JobCategory = '$cat_job'"; # 3
  $result  = mysql_query($query) or die('Mysql Err. 2');
  $row     = mysql_fetch_assoc($result);
  $numrows = $row['dt'];  # 4

  $maxPage = ceil($numrows/$recordsPerPage);

  $nav = '';
  for($page = 1; $page <= $maxPage; $page++)
  {
       if ($page == $pageNum)
       {
            $nav .= "<div class=\"pNo\">$page</div>";
       }
      else
       {
            $nav .= "<div class=\"pNo\"><a href=\"?p=$page&cat=$cat_job\">$page</a></div>";
       }
  }

  if ($pageNum > 1)  {

       $page = $pageNum - 1;
       $prev = "<a href=\"?p=$page&cat=$cat_job\"><strong>Prev</strong></a>";

       $first = "<a href=\"?p=1&cat=$cat_job\"><strong>First</strong></a>";
  }
  else {
       $prev  = '<strong>  </strong>';
       $first = '<strong>   </strong>';
  }

  if ($pageNum < $maxPage) {
       $page = $pageNum + 1;
       $next = "<a href=\"?p=$page&cat=$cat_job\"><strong>Next</strong></a>";

       $last = "<a href=\"?p=$maxPage&cat=$cat_job\"><strong>Last</strong></a>";
  }
  else {
       $next = '<strong>  </strong>';
       $last = '<strong>   </strong>';
  }
  
  echo "<table border=0 align=right  cellspacing=0 cellpadding=0 style=\"margin-right: 20px\">
  				<tr>
  				<td>$first</td>
  				<td>$prev</td>
  				<td>$nav</td>
  				<td>$next</td>
  				<td>$last</td>
  			</table>";
 //---------------------------------------PAGING----------------------------------------
 ?>	
 
			</table>
		</td>
	</tr>
</table>



<? include_once('../footer.php'); ?>
					
					